<?php

namespace Drupal\shusy_product_miaosha\ViewsController;

use Drupal\shusy_product_miaosha\ViewsController\handler\field\ShusyProductMiaoshaAmount1ViewsField;
use Drupal\shusy_product_miaosha\ViewsController\handler\field\ShusyProductMiaoshaAmount2ViewsField;
use Drupal\shusy_product_miaosha\ViewsController\handler\field\ShusyProductMiaoshaAmountTypeViewsField;
use Drupal\shusy_product_miaosha\ViewsController\handler\field\ShusyProductMiaoshaEditLinkViewsField;
use Drupal\shusy_product_miaosha\ViewsController\handler\field\ShusyProductMiaoshaStatusViewsField;
use Drupal\shusy_product_miaosha\ViewsController\handler\filter\ShusyProductMiaoshaAmountTypeViewsFilter;
use Drupal\shusy_product_miaosha\ViewsController\handler\filter\ShusyProductMiaoshaStatusViewsFilter;
use EntityDefaultViewsController;


class ShusyProductMiaoshaViewsController extends EntityDefaultViewsController {

  public function views_data() {
    $data = parent::views_data();
    if (!empty($this->info['base table'])) {
      $table = $this->info['base table'];
      $info = [];

      $info[$table]['edit_link'] = [
        'title' => t('编辑'),
        'help' => t('编辑.'),
        'field' => [
          'handler' => ShusyProductMiaoshaEditLinkViewsField::class,
        ],
      ];
      $info[$table]['amount_type'] = [
        'title' => '拼团价格模式 1 固定金额 2 比例折扣',
        'help' => '拼团价格模式 1 固定金额 2 比例折扣',
        'real field' => 'amount_type',
        'field' => [
          'handler' => ShusyProductMiaoshaAmountTypeViewsField::class,
        ],
        'filter' => [
          'handler' => ShusyProductMiaoshaAmountTypeViewsFilter::class,
        ],
      ];
      $info[$table]['amount_1'] = [
        'title' => '固定金额',
        'help' => '固定金额',
        'real field' => 'amount_1',
        'field' => [
          'handler' => ShusyProductMiaoshaAmount1ViewsField::class,
        ],
      ];
      $info[$table]['amount_2'] = [
        'title' => '比例折扣',
        'help' => '比例折扣',
        'real field' => 'amount_2',
        'field' => [
          'handler' => ShusyProductMiaoshaAmount2ViewsField::class,
        ],
      ];
      $info[$table]['status'] = [
        'title' => '状态 0 禁用 1 启用',
        'help' => '状态 0 禁用 1 启用',
        'real field' => 'status',
        'field' => [
          'handler' => ShusyProductMiaoshaStatusViewsField::class,
        ],
        'filter' => [
          'handler' => ShusyProductMiaoshaStatusViewsFilter::class,
        ],
      ];
      $data = drupal_array_merge_deep($data, $info);
    }
    return $data;
  }
}
